package com.ruoyi.system.mapper.evaluation;

import com.ruoyi.system.domain.evaluation.Evaluation;
import com.ruoyi.system.domain.evaluation.EvaluationEnity;
import com.ruoyi.system.domain.evaluation.Store;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 评价管理模块
 */
public interface EvaluationMapper {
    //用户的评价信息
    @Select("select * from ry.evaluation order by time desc")
    List<Evaluation> selectEvaluation();

    //查看不同商铺的打分信息
   @Select("select * from ry.store order by score desc ")
    List<Store> selectAllStore();

    //根据不同地点，查看商铺评价信息
    @Select("select * from ry.store where location_id =#{location_id}")
    List<Store>  selectStoreByLocation_id( int location_id);
    @Select("select name,score from ry.store  order by score desc ")
    List<EvaluationEnity> selectEvaluation2();
    //一键剔除异常数据
    @Delete("delete from ry.evaluation where score=0")
    int deleteEvaluationByScore();
    //剔除选定的id的数据
    @Delete("delete from ry.evaluation where id= #{id}")
    int deleteEvaluationById(int id);

    //删除数据
    @Delete("<script>" +
            "delete from ry.evaluation where id in" +
            "<foreach collection='array' item='id' open='(' separator=',' close=')'>" +
            "#{id}" +
            "</foreach>" +
            "</script>")
    int deleteEvaluation(Long[] ids);

    //查询评价数据+locationName
    @Select("select e.id,l.id as 'location_id',e.store_id,e.score,time,user_id,s.name as'storeName',l.name as 'locationName' from ry.evaluation e left join ry.store s on e.store_id=s.id left join ry.location l on s.location_id=l.id  order by time desc  ")
    List<EvaluationEnity> selectEvaluationName();
}
